<?php
	include_once 'isLogin.php';

	if($_GET['action']=="name"){
		$sql="admin where `name`='".$_GET['name']."'";
		$num = $commonc->getNum($sql);
		if($num<=0){
			echo "1";
		}else{
			echo "0";
		}
		exit();
	}
	
	if($_POST['submit']){
		unset($_POST['submit']);
		unset($_POST['pwd2']);
		$_POST['pwd']=md5($_POST['pwd']);
		$commonc->insert("admin",$_POST);
		echo "<script>
				alert('保存成功');
				window.location.href='admin_add.php';
			</script>";
	}
	
	$group = $commonc->getList("admin_groups");
	$smarty->assign("group",$group['result']);
	
	$smarty->display("admin_add.html");
?>